<template>
  <div class="center-container">
    <el-form  label-width="80px" class="login-form">
      <el-form-item label="用户名" >
        <el-input v-model="loginForm.username" placeholder="请输入用户名"> </el-input>
      </el-form-item>
      <el-form-item label="密码" >
        <el-input type="password" v-model="loginForm.password" placeholder="请输入密码"> </el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="login">登录</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>
  
  <script lang="ts">
  import { defineComponent, ref } from 'vue';
  import { ElForm, ElFormItem, ElInput, ElButton } from 'element-plus';
  import { useRouter } from 'vue-router'; 
  
  export default defineComponent({
    components: {
      ElForm,
      ElFormItem,
      ElInput,
      ElButton
    },
    setup() {
      const router = useRouter();
      const loginForm = ref({
        username: '',
        password: ''
      });
  
      const login = () => {
        // 在这里编写登录逻辑
        console.log('用户名:', loginForm.value.username);
        console.log('密码:', loginForm.value.password);
        router.push('/mainpage');
      };
  
      return {
        loginForm,
        login
      };
    }
  });
  </script>
  
  <style>
  .login-form {
    max-width: 400px;
    margin: 0 auto;
    padding: 20px;
    border: 1px solid #eee;
    border-radius: 5px;
    text-align: center; /* 将居中显示 */
    font-size: 1.2em; /* 增大一号字体 */
  }

  .center-container {
    display: flex;
    /*justify-content: center;*/
    align-items: center;
    height: 70vh; /* 可根据需要调整高度 */
  }
  </style>
  
  